#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back
#define vec vector<int>

int read(){int x = 0,sgn = 1;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);return x*sgn;}

const int N = 1e3+10;
const int mod = 1e9 + 7;

ll fac[N],ifac[N];
ll f[N][N],g[N][N];
int a,b,n,c,d;

ll C(int x,int y){return x < 0 || y < 0 || x < y ? 0 : fac[x] * ifac[y] % mod * ifac[x - y] % mod;}

ll qp(ll x,int t){ll res=1;for(;t;t >>= 1,x = x * x % mod) if(t & 1) res = res * x % mod;return res;}

void init(int l){
	for(int i = (fac[0] = 1);i <= l;i++) fac[i] = fac[i-1] * i % mod; ifac[l] = qp(fac[l],mod-2);
	for(int i = l - 1;i >= 0;i--) ifac[i] = ifac[i + 1] * (i + 1) % mod;
}

template <typename T>void upd(T &x,T y){x = (x + y) % mod;}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	init(1000);
	n = in,a = in,b = in,c = in,d = in;
	for(int i = a;i <= b;i++)
		for(int k = c;k <= d && i * k <= n;k++){
			g[i][k] = 1;
			for(int al = i * k;al;al -= i) g[i][k] = g[i][k] * C(al,i) % mod;
			g[i][k] = g[i][k] * ifac[k] % mod;
		}
	f[a-1][0] = 1;
	for(int i = a;i <= b;i++){
		for(int j = 0;j <= n;j++){
			f[i][j] = f[i-1][j];
			for(int nu = c;nu <= d && nu * i <= j;nu++)
				upd(f[i][j],f[i-1][j - nu * i] * C(n - (j - nu * i),nu * i) % mod * g[i][nu] % mod);
		}
	}
	printf("%lld\n",f[b][n]);
	return 0;
}
